﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PersonaLibrary.Data
{
    public partial class Note
    {
        private EventsEntitySet<EmployeeNoteLink> lazeLinks;
        private bool canLazeLinksLoad;

        public EventsEntitySet<EmployeeNoteLink> LazeLinks
        {
            get
            {
                if(lazeLinks == null && canLazeLinksLoad)
                {
                    lazeLinks = new EventsEntitySet<EmployeeNoteLink>(EmployeeNoteLinks)
                                    {
                                        EntityAddedFilter = x => x.NoteId == Id
                                    };
                }
                return lazeLinks;
            }
        }

        public void LoadLinks()
        {
            canLazeLinksLoad = true;
            SendPropertyChanged("LazeLinks");
        }

        public override void Detach()
        {
            EmployeeNoteLinks = default(System.Data.Linq.EntitySet<EmployeeNoteLink>);
            base.Detach();
        }

        public override string ToString()
        {
            return Name;
        }
    }
}
